package main

import "fmt"

type Student struct {
}

//类型断言最佳实践
func TypeJudge(items ...interface{}) {
	if len(items) == 0 {
		fmt.Println("没有输入参数")
		goto exit
	}
	for _, v := range items {
		switch v.(type) {
		case bool:
			fmt.Println("布尔")
		case float32, float64:
			fmt.Println("浮点")
		case int, int16, int32, int64, int8, uint, uint16, uint32, uint64, uint8:
			fmt.Println("整数")
		case []string:
			fmt.Println("字符串切片")
		case string:
			fmt.Println("字符串")
		case [2]string:
			fmt.Println("两个元素的字符串数组")
		case Student:
			fmt.Println("Student结构体")
		case *Student:
			fmt.Println("Student结构体指针")
		default:
			fmt.Println("其他")
		}
	}
	fmt.Println("------------------------------------------------")
	fmt.Println("判断完毕")
exit:
}

func main() {
	var empty interface{}
	var stu Student
	empty = stu
	stu1 := empty.(Student)
	TypeJudge('a', "a", 44, 21.22, [2]string{"a", "b"}, []string{"a", "b"}, true, stu1, &stu)
}
